# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
class Solution:
    def preorderTraversal(self, root: TreeNode) -> list[int]:
        if root == None:
            return []
        res = []
        res.append(root.val)
        return res + self.preorderTraversal(root.left) + self.preorderTraversal(root.right)


range()